package com.yxj01;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamDemo04 {
    public static void main(String[] args) {
//       try {
//           FileOutputStream fos = new FileOutputStream("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt");
//           fos.write("hello".getBytes());
//           fos.close();
//       }catch (IOException e) {
//           e.printStackTrace();
//       }

        //finally
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt");
            fos.write("hello".getBytes());
        }catch (IOException e) {
            e.printStackTrace();
        }finally {
           if(fos != null) {
               try{
                   fos.close();
               }catch (IOException e) {
                   e.printStackTrace();
               }
           }
        }
    }
}
